package demo.spring.test180316;

import demo.spring.UnitTestBase;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Description:
 * @Author:tyzhang
 * @Date: Created in 16:02 2018/3/16
 */
@RunWith(BlockJUnit4ClassRunner.class)
public class TestBeanScope extends UnitTestBase {
    public TestBeanScope() {
        super("classpath*:spring-beanScope.xml");
    }

    @Test
    public void testSingleton() {
        BeanScope beanScope = super.getBean("beanScope");
        beanScope.say("你好！");
    }

    @Test
    public void testSingleton1() {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring-beanScope.xml");
        BeanScope beanScope = (BeanScope) applicationContext.getBean("beanScope");
        beanScope.say("你好！");
    }

}
